#!/usr/bin/env python3

import os
import sys
import os.path


def main(args):
    result = dict()
    for relpath in args:
        if os.access(relpath, os.F_OK):
            for cur, dirs, files in os.walk(relpath):
                if cur == relpath or os.path.basename(cur)[0] != '.':
                    for elem in sorted(dirs + files):
                        if elem[0] != '.':
                            for char in elem:
                                if not char in result:
                                    result[char] = 1  # 9 levels of indentation
                                else:
                                    result[char] += 1  # holy shit man
    result = sorted(result.items(), key=(lambda t: t[1]))
    for char, freq in result:
        print("{0} - {1:3d}".format(char, freq))
    return result

if __name__ == "__main__":
    assert len(sys.argv) > 1, "No paths specified"
    main(sys.argv[1:])
